package com.api.shopapi.service.impl;

import com.api.shopapi.entity.AlarmRecord;
import com.api.shopapi.entity.dto.AlarmRecordDTO;
import com.api.shopapi.mapper.AlarmRecordMapper;
import com.api.shopapi.service.AlarmRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("AlarmRecordServiceImplOne")
public class AlarmRecordServiceImpl implements AlarmRecordService {

    @Autowired
    private AlarmRecordMapper alarmRecordMapper;

    @Override
    public int insert(AlarmRecord alarmRecord) {
        return alarmRecordMapper.insert(alarmRecord);
    }

    @Override
    public int update(AlarmRecord alarmRecord) {
        return alarmRecordMapper.update(alarmRecord);
    }

    @Override
    public AlarmRecord getByAlarmRecordCode(String alarmRecordCode) {
        return alarmRecordMapper.getByAlarmRecordCode(alarmRecordCode);
    }

    @Override
    public List<AlarmRecord> getList() {
        return alarmRecordMapper.getList();
    }

    @Override
    public PageInfo<AlarmRecordDTO> getListPage(int pageIndex, int pageSize, Integer type,
                                                Date startTime,
                                                Date endTime,
                                                String governmentCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<AlarmRecordDTO> alarmRecordList =alarmRecordMapper.getListPage(type,startTime,endTime,governmentCode);
        return new PageInfo<>(alarmRecordList);
    }

    @Override
    public PageInfo<AlarmRecordDTO> getListPageByUserCode(int pageIndex, int pageSize,String userCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<AlarmRecordDTO> alarmRecordList =alarmRecordMapper.getListPageByUserCode(userCode);
        return new PageInfo<>(alarmRecordList);
    }

    @Override
    public List<AlarmRecord> getListByUserCode(String userCode) {
        return alarmRecordMapper.getListByUserCode(userCode);
    }
}
